<?php
/* @var $this BodegaSateliteController */
/* @var $model bodegaSatelite */
/* @var $form CActiveForm */
?>


	<?php if (Yii::app()->user->hasFlash('success')): ?>
	<div class="alert alert-success">
		<?php echo Yii::app()->user->getFlash('success'); ?>
	</div>
<?php endif ?>
<?php if (Yii::app()->user->hasFlash('error')): ?>
	<div class="alert">
		<?php echo Yii::app()->user->getFlash('error'); ?>
	</div>
<?php endif ?>

<div class="form">

<!--  Tooltip-->
<?php
$this->widget('application.extensions.tipsy.Tipsy', array(
  'fade' => false,
  'gravity' => 'n',
  'items' => array(
    array('id' => '.tooltipster'),
    array('id' => '#tooltipster'),
    array('id' => array('model' => $model, 'attribute' => 'model_attribute_name')
     ,'fallback' => 'Put custom tooltip here.' ),    
  ),  
));
?>



<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'bodega-satelite-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

	

	<?php echo $form->errorSummary($model); ?>
	<div>

	<?php echo $form->textField($model,'documento', array("class"=>"form-inline ",'placeholder'=>'Formula 28')); ?>
		<?php echo $form->error($model,'documento'); ?>
	   
		<?php //echo $form->textField($model,'codigo',array("class"=>"form-inline ",'placeholder'=>'Código del productos')); ?>
		<?php //echo $form->error($model,'codigo'); ?>		
		<?php echo $form->error($model,'codigo'); ?>
		<?php echo $form->hiddenField($model,'codigo',array( "class"=>"form-inline"));
		$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
			'name'=>'codigo',
			 'attribute'=>'codigo',
			'model'=>$model,
			'sourceUrl'=>$this->createUrl('ListarEstados'),
			'htmlOptions'=>array('placeholder'=>'Código del producto'),
			'options'=>array(
			'placeholder'=>'Código del productos',
				'minLength'=>'1',
				'showAnim'=>'fold',
			'select' => 'js:function(event, ui)
				{ jQuery("#Contrato_estado").val(ui.item["id"]); }',
				'search'=> 'js:function(event, ui)
				{ jQuery("#Contrato_estado").val(0); }'
				),
			)); ?>

		<?php echo $form->textField($model,'cantidad',array("class"=>"form-inline ",'placeholder'=>'Cantidad')); ?>
		<?php echo $form->error($model,'cantidad'); ?>
		 <?php echo $form->dropDownList($model,'servicio',servicios::tolist2(),array('empty'=>'Seleccione un servicio','style'=>'width:21%')); ?>
		<?php echo $form->error($model,'servicio'); ?>

		<?php echo $form->textField($model,'nombrepersona',array("class"=>"form-inline ",'placeholder'=>'Empleado retira pedido')); ?>
		<?php echo $form->error($model,'nombrepersona'); ?>

		
	</div>




	<div class="row buttons">
		<?php echo CHtml::submitButton('Agregar',array("class"=>"btn btn-primary")); ?>
		
	</div>

	<?php $this->widget('bootstrap.widgets.TbGridView', array(
	'type'=>'striped bordered condensed',
	'id'=>'usuarios-grid',
	'dataProvider'=>$model->search(),
	//'filter'=>$model,
	'template'=>"{summary}{items}{pager}",
	'itemsCssClass'=>'table table-striped table-bordered table-condensed tableNews',// mover por fila
    'enablePagination' => true,
	'columns'=>array(
		array('name'=>'codigo', 'header'=>'Código'),
        //array('name'=>'descripcion', 'header'=>'Descripcion'),
        array('name'=>'cantidad', 'header'=>'Cantidad despachada'),
        array('name'=>'servicio', 'header'=>'Servicio'),
         array('name'=>'documento', 'header'=>'Documento'),
         array('name'=>'nombrepersona', 'header'=>'Empleado'),

		array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
             'htmlOptions'=>array('style'=>'width: 70px'),
             'template'=>'{dele}',
             'buttons'=>array
			         (
			         			            
			           'dele' => array
			                (
			                    'label'=>'Eliminar','icon'=>'off',
			                    //'imageUrl'=>'$model->activeImg($data->id)',	
			                  	//'imageUrl'=>Yii::app()->request->baseUrl.'/images/sus.png',
			                  	'url'=>'Yii::app()->createUrl("/Descuento/dele?id=$data->codigo")',  
			                  	'afterDelete'=>'$.fn.yiiGridView.update("usuarios-grid");',               
			                              
			                ),
			          ),	           

			        ),

	),
)); ?>
<?php echo CHtml::submitButton('Aplicar',array('name'=>'Aplicar',"class"=>"btn btn-primary")); ?>
<?php $this->endWidget(); ?>


</div><!-- form -->


